'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { STRING, DATE, BOOLEAN, INTEGER } = Sequelize;
    await queryInterface.createTable("sys_user", {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment: "主键id，自增",
      },
      username: {
        type: STRING(32),
        unique: true,
        allowNull: false,
        comment: "用户名",
      },
      password: {
        type: STRING(50),
        allowNull: false,
        comment: "密码",
      },
      nickname: {
        type: STRING(32),
        allowNull: false,
        comment: "昵称",
      },
      mobile: {
        type: STRING(11),
        unique: true,
        comment: "手机号",
      },
      email: {
        type: STRING(50),
        comment: "邮箱",
      },
      status: {
        type: BOOLEAN,
        defaultValue: true,
        comment: "状态 true：有效  false：冻结",
      },
      userType: {
        type: STRING(2),
        defaultValue: '1',
        comment: '0：管理员账号  1:普通账号'
      },
      loginIp: {
        type: STRING(50),
        comment: "登录IP",
      },
      loginTime: {
        type: DATE,
        comment: "登录时间",
      },
      createById: {
        type: STRING(36),
        comment: "创建人ID",
      },
      createTime: {
        type: DATE,
        comment: "创建时间",
      },
      updateById: {
        type: STRING(36),
        comment: "更新人Id",
      },
      updateTime: {
        type: DATE,
        comment: "更新时间",
      },
      delFlag: {
        type: BOOLEAN,
        defaultValue: false,
        comment: "状态 true：已删  false：未删",
      },
    })
  },

  down: async (queryInterface) => {
    await queryInterface.dropTable("sys_user");
  },
};
